x = input()y = ''for i in x:    if (i == '(' or i == '{' or i == '[' or i == '<') or y == '':        y += i    elif y != '':        if (i == ')' and y[-1] == '(') or (i == '}' and y[-1] == '{') or (i == ']' and y[-1] == '[') or (i == '>' and y[-1] == '<'):            y = y[:-1]if y == '':    print(True)else:    print(False)